import 'package:flutter/material.dart';
//import 'package:fluttertoast/fluttertoast.dart';
import 'package:flutter_app/widget/AppBarTemp.dart';
import 'package:flutter_app/utils/windowUtil.dart';
class HuodongZhongxin extends StatefulWidget {
  @override
  State<HuodongZhongxin> createState() => _HuodongZhongxinState();
}

class _HuodongZhongxinState extends State<HuodongZhongxin> {
  List<String> list=['活动商品','品牌','家族','男鞋','家纺','居家百货','男装','美妆'];
  List<String> item=['泉林本色健康本色家用面巾纸360张9包纸品抽纸组合','菜子王纯正压榨菜籽油5L 非转基因食用健康植物油四川特产 约10斤','福临门 葵花籽清香食用植物调和油 5L/桶 健康食用油','泉林本色抽纸环保公益健康本色纸巾170抽*18包纸品组合装','膜法世家绿豆控油3件套 爽肤水洁面乳液补水保湿清洁护肤套装男女'
  ,'Hanhoo/韩后茶蕊去角质素 清洁毛孔洁面去死皮去黑头磨砂膏60g','隆力奇去皱绿茶男士SOD蜜90ml补水保湿滋润乳液面霜活力脸部肌肤','今之逸品300抽化妆棉卸妆棉女薄款脸部湿敷专用纯棉省水收纳盒装','Nature Republic自然共和国芦荟胶晒后修护*3支装'

  ];
  int index=0;
  @override
  void initState() {
    print("huodong");
    super.initState();
//    Fluttertoast.showToast(msg: "活动中心");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarTemp(

       "天猫活动都在这里",
        color: Colors.red,
      )
      ,
      body:

              Stack(children: <Widget>[
                ListView.builder(
                  padding: EdgeInsets.only(top: 50.0),
                    itemCount: item.length,
                    itemBuilder: (_,int index){
                  return Container(
                    margin: EdgeInsets.only(left: 20.0,right: 20.0),
                    padding: EdgeInsets.only(top: 20.0,bottom: 20.0),
                    child: Row(
                      children: <Widget>[

                        Container(
                          margin: EdgeInsets.all(10.0),
                          width: windowUtil.width*1/3,height: windowUtil.width/3,
                        decoration: BoxDecoration(
                          color: Color(0xffF0FFFF),
                          borderRadius: BorderRadius.circular(2.0)
                        ),
                          child: Image.asset("images/ex3.png",width: 90.0,height: 90.0,),
                        ),
                        Expanded(child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,

                          children: <Widget>[
                            Text(item[index],style: TextStyle(color: Colors.black,fontSize: 19.0,fontWeight: FontWeight.bold),),
                            Container(
                              decoration: BoxDecoration(borderRadius: BorderRadius.circular(2.0),border: Border.all(color: Colors.red,width: 1.0)),
                              child: Text("只要9.9",style: TextStyle(color: Colors.red),),
                            )

                          ],
                            crossAxisAlignment:CrossAxisAlignment.start
                        ),

                        ),


                        
                      ],
                      
                      
                    ),
                    
                  );
                  
                }),
                 Container(
                   color: Color(0xffffffff),
                   height: 40.0,
                   width: windowUtil.width,
                   child:Column(children: <Widget>[
                   Container(
                     height:38.0,
                     child:
                   ListView.builder(
                     itemCount: list.length,
                     scrollDirection: Axis.horizontal,
                     itemBuilder: (_,int id){
                       return getitem(list[id], id);

                     },

                   )
                     ,),

                   Container(height: 2.0,color: Colors.grey,)
                   ],

                   )

                 ),







         ],
      ),
    );
  }

  Widget getitem(String s ,int index){
    return
    GestureDetector(child:  Container(height: 38.0,
      child: Row(children: <Widget>[
        Container(padding: EdgeInsets.only(left: 5.0,right: 5.0),child: Text(s,style: TextStyle(color:this.index==index?Colors.red: Colors.grey),),)
        ,Container(width: 1.0,height: 20.0,color: Colors.grey,)
      ],),
    ),
    onTap: (){
      this.index=index;
      setState(() {

      });

    },
    )
     ;

  }
}